﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Themes/Default/Views/Shared/Site.Master" %>

<%@ Import Namespace="AFDS.BusinessLogic" %>
<%@ Import Namespace="AFDS.Core" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<% Html.RenderPartial("AFDSSubMenu");%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">    
<% var sites = (ViewData["Sites"] as List<Site>); %>
<fieldset class="MvcMembership">

<% Html.BeginForm("SitesList", "AFDSAdmin"); %>

	<legend><h1><%=ViewData["Title"] %></h1></legend>
<div style="padding-bottom: 15px; padding-top: 5px;">
  <b>Order By:</b>&nbsp;
  <%=Html.DropDownList("OrderBySelect", (SelectList)ViewData["OrderByItems"], new { onchange = "document.getElementsByTagName('form')[0].submit()" }) %> &nbsp;
  |&nbsp;&nbsp;<b>Filter:</b> &nbsp;
  <%=Html.DropDownList("FilterSelect", (SelectList)ViewData["FilterItems"], new { onchange = "document.getElementsByTagName('form')[0].submit()" })%> &nbsp;|&nbsp;

  
  <%if (SortFactor.ASC == (SortFactor)ViewData["SortFactor"]) { %>
    <%=Html.RadioButton("SortFactor", "descending", false, new { onchange = "document.getElementsByTagName('form')[0].submit()" })%> Descending
    <%=Html.RadioButton("SortFactor", "ascending", true, new { onchange = "document.getElementsByTagName('form')[0].submit()" })%> Ascending
  <%} else { %>
    <%=Html.RadioButton("SortFactor", "descending", true, new { onchange = "document.getElementsByTagName('form')[0].submit()" })%> Descending
    <%=Html.RadioButton("SortFactor", "ascending", false, new { onchange = "document.getElementsByTagName('form')[0].submit()" })%> Ascending    
    
    <%
    }
    %>  
   
</div>
 
	<% if (sites != null && sites.Count > 0)
    { %>	
	<table width="100%" cellspacing=2>
	    <tr style="background-color: #c9cccd; height: 14px; text-align:center; font-weight: bold;">
            <td>Name:</td><td>Category:</td><td>URL:</td><td>DateCreated:</td><td>Aproved:</td><td>Action:</td>
        </tr> 
		<% foreach (var s in sites)
     {
         string cat = "Null";
         if(s.Categories.Count > 0) cat = s.Categories[0].Name;
         %>
         <tr>
		<td><% = s.Name %></td><td><%= cat%></td><td><a href="<%= s.URL %>"><%= s.URL %></a></td><td><%= s.DateCreated.ToShortDateString()%></td><td><%=Html.CheckBox("isenabled", s.Approved, (object)new { @disabled = "disabled" })%></td><td><%= Html.ActionLink("EDIT", "EditSiteForm/edit", "Admin", new { id = s.Id.ToString() }, null)%> - <%= Html.ActionLink("DELETE", "EditSiteForm/delete", "Admin", new { id = s.Id.ToString() }, null)%>		
		</td>
		</tr> 
		<% } %>
	<% }else{ %>
	    <tr>
	        <td colspan="5">
	            <p>No Sites have been entered into the system yet.</p>
	        </td>
	    </tr>
	<% } %>
	    <tr>
	        <td colspan="6" style="padding-top:8px;">
	            <%= Html.ActionLink("Create a New Site", "EditSiteForm/add", "Admin", new { id = "0" }, null)%>
	        </td>
	    </tr>	
	</table>	
	<%Html.EndForm(); %>
</fieldset>

</asp:Content>
